package br.ufpe.cin.imlm2.jbeat.soot.common.filters;

import java.util.ArrayList;
import java.util.List;

import soot.SootClass;

import br.ufpe.cin.imlm2.util.filter.CompositeFilter;
import br.ufpe.cin.imlm2.util.filter.IFilter;

/**
 * A composite filter for <code>SootClass</code> objects.
 * 
 * @author Irineu
 * 
 */
public class CompositeSootClassFilter extends SootClassFilter implements
		CompositeFilter<SootClass> {

	private List<IFilter<SootClass>> filters = new ArrayList<IFilter<SootClass>>();

	@Override
	public boolean retains(SootClass t) {
		boolean retains = false;
		for (IFilter<SootClass> f : this.filters) {
			retains = f.retains(t) || retains;
		}
		return retains;
	}

	@Override
	public void addFilter(IFilter<SootClass> anotherFilter) {
		if (!this.filters.contains(anotherFilter))
			this.filters.add(anotherFilter);
	}

	@Override
	public void removeFilter(IFilter<SootClass> anotherFilter) {
		if (this.filters.contains(anotherFilter))
			this.filters.remove(anotherFilter);
	}

}
